package com.rss.model;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DatabaseHelper extends SQLiteOpenHelper {

	private static final String DATABASE_NAME = "rss.db";
	private static final int DATABASE_VERSION = 1;
	public static final String TABLE_NAME = "weathers";
	public static final String WEATHER_ID = "_id";
	public static final String WEATHER_NAME = "name";
	public static final String WEATHER_PATH = "path";

	// Database creation sql statement
	private static final String DATABASE_CREATE = "CREATE TABLE " + TABLE_NAME
			+ "( " + WEATHER_ID + " integer primary key autoincrement, "
			+ WEATHER_NAME + " text not null, " + WEATHER_PATH + " text not null);";

	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		// TODO Auto-generated method stub
		System.out.println(DATABASE_CREATE);
		database.execSQL(DATABASE_CREATE);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		Log.w(DatabaseHelper.class.getName(),
				"Upgrading database from version " + oldVersion + " to"
						+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);

	}

}
